#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author  : Lee
# @File    : connect_row_calc.py
# @Time    : 2024/1/16 11:24
from util.common_calc import *
from util.global_config import global_config
from util.get_localization_points import GetLocalizationPoints


class GetConnectRowAverPoint:
    def __init__(self, line_points, point_a, point_b):
        self.line_points = line_points
        self.point_a = point_a
        self.point_b = point_b

    def get_connect_row_aver_point(self):
        """
        分别以均分数值、均分轨迹长度，均分在基准线上投影长度
        :return:
        """

        _p_obj = GetLocalizationPoints([self.point_a, self.point_b], 0, self.line_points, global_config["aver_count"])

        # 计算基准线直线方程
        a, b, c = calc_baseline_equation(self.point_a, self.point_b)

        # 获取起始线和终止线在AB线上的投影坐标，并将投影间距离平均分成49份
        _a = get_intersection(self.point_a, self.point_b, self.line_points[0])
        _b = get_intersection(self.point_a, self.point_b, self.line_points[-1])
        _average_points = ior_calc_average_divide_line(_a, _b, global_config["aver_count"])

        _aver_line = _p_obj.get_aver_point("ave_line", self.line_points, _average_points, a, b, c, True)
        _aver_count = _p_obj.get_aver_point("ave_counts", self.line_points, _average_points, a, b, c, True)
        _aver_trajectory = _p_obj.get_aver_point("ave_trajectory", self.line_points, _average_points, a, b, c, True)
        return _aver_line, _aver_count, _aver_trajectory
